package com.waimai.mobile.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.waimai.mobile.R;
import com.waimai.mobile.ui.WaiMaiApp;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.App;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

/**
 * Created by lin on 2015/6/17.
 */
@EActivity(R.layout.activity_user_detail)
public class UserDetailActivity extends BaseActivity02{

    @App
    public WaiMaiApp app;

    @ViewById(R.id.toUserNameActivityLL)
    public LinearLayout toUserNameActivityLL;

    @ViewById(R.id.toUserPhoneActivityLL)
    public LinearLayout toUserPhoneActivityLL;

    @ViewById(R.id.toPasswordActivityLL)
    public LinearLayout toPasswordActivityLL;

    @ViewById(R.id.logoutBtn)
    public Button logoutBtn;

    @ViewById(R.id.userNameTv)
    public TextView userNameTv;

    @ViewById(R.id.phoneTv)
    public TextView phoneTv;

    @AfterViews
    public void afterViews(){
        setActionBarTitle("我的账户");
    }

    @Override
    protected void onResume() {
        super.onResume();
        userNameTv.setText(app.getUser().getUserName());
        phoneTv.setText(app.getUser().getPhone());
    }

    @Click(R.id.toUserNameActivityLL)
    public void toUserNameActivityLLClick(View v){
        Intent intent = new Intent(getApplicationContext(), UserNameActivity_.class);
        startActivity(intent);
    }

    @Click(R.id.toUserPhoneActivityLL)
    public void toUserPhoneActivityLLClick(View v){
        Toast.makeText(this, "抱歉，暂不提供修改手机号", Toast.LENGTH_SHORT).show();
    }

    @Click(R.id.toPasswordActivityLL)
    public void toPasswordActivityLLClick(View v){
        Intent intent = new Intent(getApplicationContext(), PasswordActivity_.class);
        startActivity(intent);
    }

    @Click(R.id.logoutBtn)
    public void logoutBtnClick(View v){
        app.setUser(null);
        onBackPressed();
        finish();
    }
}
